package com.miles.servlet.user;

import com.alibaba.fastjson.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

public class TestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String method = req.getParameter("method");
        String vue = req.getParameter("vue");
        System.out.println("==="+vue);
        Map<String,String> map = new HashMap();
        PrintWriter pw = null;
        if(method.equals("test")){
           if (vue==null||vue==""){
               map.put("meassag","null");
           }
            pw= resp.getWriter();
            resp.setContentType("application/json");
            Object json= JSONArray.toJSON(map);
            pw.write(json.toString());
            pw.flush();
            pw.close();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    }
}
